fn main() {
    
    let mut user1 = User{
        active : true,
        username : String::from("zhangsan"),
        email : String::from("zhangsan@qq.com"),
        sign_in_count : 10,
    };

    user1.email = String::from("this is eitd mail");

    println!("name:{} email:{}",user1.username, user1.email);

    let user2 = creat_user(String::from("lisi"),String::from("lisi@qq.com"));
    println!("name:{} email:{}",user2.username, user2.email);

    let user3 = creat_user_shorthand(String::from("wanger"),String::from("wanger@qq.com"));
    println!("name:{} email:{}",user3.username, user3.email);

    let user4 = User{
        active : true,
        username : user1.username,
        email : String::from("user4@qq.com"),
        sign_in_count : 10
    };
    println!("name:{} email:{}",user4.username, user4.email);

    let user5 = User{
        email : String::from("user5@qq.com"),
        ..user2
    };
    println!("name:{} email:{}",user5.username, user5.email);


    // ------------------- Tuple Struct ------------------------------
    struct Color(u8,u8,u8,u8);
    struct Point(i16,i16,i16);

    let green = Color(0,255,0,255);
    let Color(r,g,b,a) = green;
    println!("r:{} g:{} b:{} a:{}",r,g,b,a);
    let origin = Point(0,0,0);
    // 通过索引访问
    let x: i16 = origin.0;
    let y: i16 = origin.1;
    let z: i16 = origin.2;
    println!("x:{} y:{} z:{}",x,y,z);
}

struct User {
    active : bool,
    username : String,
    email : String,
    sign_in_count : u64,
}

fn creat_user(username : String,email : String) -> User{
    User{
        active : true,
        username : username,
        email : email,
        sign_in_count : 10,
    }
}

fn creat_user_shorthand(username : String,email : String) -> User{
    User{
        active : true,
        username,
        email,
        sign_in_count : 10,
    }
}